function yout = myinterp1(x, y, xout)
  % function does not input checking whatsoever to speed up things maximally
  % user is responsible for doing this himself.

  % furthermore, assume the input and output grids x and xout are sorted in an increasing order

  % linear interpolation
  
  yout = zeros(length(xout), 1);

  ci = 1;
  dx = 0;
  fx = 0;
  dy =  0;
  for i=1:length(xout)
    while x(ci) <= xout(i)
      ci = ci+50;
    end
    while x(ci) > xout(i)
      ci = ci-4;
      if (ci <= 0)
        ci = 1;
        break;
      end
    end
    while x(ci) <= xout(i)
      ci = ci+1;
    end

    fx = xout(i) - x(ci);
    dx = x(ci) - x(ci-1);
    dy = y(ci) - y(ci-1);
    yout(i) = y(ci) + dy.*(fx./dx);
  end

end
